import request from "@/api/request";
import type { SunnyVariable } from "@/types/sunnyVariable/type";
import type { AxiosPromise } from "axios";

export function listVariablesApi(
  projectId: number
): AxiosPromise<SunnyVariable[]> {
  return request({
    url: "/sunnyVariable/" + projectId,
    method: "get",
  });
}

export function addVariablepi(
  data: SunnyVariable
): AxiosPromise<SunnyVariable[]> {
  return request({
    url: "/sunnyVariable/",
    method: "post",
    data,
  });
}

export function updateVariablesApi(
  data: SunnyVariable
): AxiosPromise<SunnyVariable[]> {
  return request({
    url: "/sunnyVariable/",
    method: "put",
    data,
  });
}

/**
 * 前端提交的时候只有单个删除的功能
 * @param projectId
 * @returns
 */
export function deleteVariablesApi(
  projectId: number
): AxiosPromise<SunnyVariable[]> {
  return request({
    url: "/sunnyVariable/" + projectId,
    method: "delete",
  });
}
